<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">
    <body>
        <h:panelGrid columnClasses="column1,column1,column1" columns="3">
		<h:panelGrid columns="2">
		    <h:outputLabel value="Teslim tarihi: "/>
                    <h:outputLabel value="#{HomeworkBean.target.date.toLocaleString()}"/>
		    <h:outputLabel value="Detay: "/>
		    <h:outputLabel value="#{HomeworkBean.target.text}"/>
		    <h:outputLabel value="Dosyalar: "/>
		    <p:dataList var="file" value="#{HomeworkBean.target.files}">
			  <p:column>
				<h:panelGrid columns="1">
				<p:commandLink ajax="false" value="İndir">
				    <f:setPropertyActionListener value="#{file.file}" target="#{HomeworkBean.targetFile}"/>
				    <p:fileDownload value="#{HomeworkBean.convert()}"/>
				</p:commandLink>
				    <h:outputLabel value="Açıklama: #{file.information}"/>
				</h:panelGrid>
			  </p:column>
		    </p:dataList>
		</h:panelGrid>
		<p:panel header="Gönderilen Cevaplar">
                    <p:dataList var="ans" value="#{HomeworkBean.answers}">
			  <p:column>
				<h:panelGrid columns="1">
                                    <p:commandLink rendered="#{CourseBean.coursesTeacher()==true}" ajax="false" value="Cevabı Gör" action="#{HomePageBean.clickBoxAnswer()}">
                                    <f:setPropertyActionListener value="#{ans}" target="#{HomeworkBean.targetAnswer}"/>
				</p:commandLink>
				<p:commandLink value="Gönderen Öğrenci: #{ans.student.fullName}" action="#{HomePageBean.clickStudent()}" ajax="false">
				    <f:setPropertyActionListener value="#{ans.student}" target="#{StudentBean.target}"/>
				</p:commandLink>
				</h:panelGrid>
			  </p:column>
		    </p:dataList>
		</p:panel>
            
            <p:panel rendered="#{HomePageBean.box==true}"  header="Cevap">
		<ui:include src="answer.xhtml"/>
	  </p:panel>
	  </h:panelGrid>
        <h:outputLabel rendered="#{HomeworkBean.sent()==true}" value="Ödev cevabınızı gönderdiniz."/>
        <p:panel rendered="#{HomePageBean.userIsTeacher()==false and HomeworkBean.sent()==false}" header="Cevabınızı Gönderin">
		<h:panelGrid columns="2">
		    <h:outputLabel value="Dosya"/>
                    <p:fileUpload fileUploadListener="#{HomeworkBean.uploadListener}" label="Dosya Seç" update="answerMes" auto="true" multiple="true" mode="advanced"/>
		    <h:outputLabel value="Dosya açıklaması: "/>
		    <p:inputText value="#{HomeworkBean.fileInfo}"/>
		    <p:commandButton value="Cevapla" action="#{HomeworkBean.addAnswer()}" ajax="false"/>
		</h:panelGrid>
            <p:growl id="answerMes" showDetail="true"/>
	  </p:panel>
    </body>
</html>
